package com.bjsxt.controller;

import com.bjsxt.entity.Team1Dto;
import com.bjsxt.entity.User1Dto;
import com.bjsxt.entity.User2Dto;
import com.bjsxt.interfaces.Group1;
import com.bjsxt.interfaces.Group2;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lxiaol
 * @date 2021年05月21日 16:34
 */
@RestController
@RequestMapping("/api/v1")
public class Demo1Controller {

    @PostMapping("/insert")
    public String validatedDemo1(@Validated @RequestBody User1Dto user1Dto) {
        System.out.println(user1Dto);
        return "success";
    }

    @PostMapping("/insert2")
    public String validatedDemo2(@Validated @RequestBody Team1Dto team1Dto) {
        System.out.println(team1Dto);
        return "success";
    }


    @PostMapping("/insert3")
    public String validatedDemo3(@Validated @RequestBody User2Dto user2Dto) {
        System.out.println(user2Dto);
        return "success";
    }

    @PostMapping("/insert4")
    public String validatedDemo4(@Validated(Group1.class) @RequestBody User2Dto user2Dto) {
        System.out.println(user2Dto);
        return "success";
    }

    @PostMapping("/insert5")
    public String validatedDemo5(@Validated(Group2.class) @RequestBody User2Dto user2Dto) {
        System.out.println(user2Dto);
        return "success";
    }


}